using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class forums_controls_administration_AddYCode : System.Web.UI.UserControl
{
    public event EventHandler YCodeCreated;
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            DAL.YCode myYCode = new DAL.YCode();
            myYCode.Code = txtTag.Text;
            myYCode.Template = txtTemplate.Text;
            if (txtArguments.Text.Length > 0)
            {
                myYCode.TotalArguments = Convert.ToInt32(txtArguments.Text);
            }
            else
            {
                myYCode.TotalArguments = 0;
            }
            myYCode.SupportNestedTags = chkNesting.Checked;
            DAL.YCodes.Add(myYCode);

            txtTag.Text = "";
            txtTemplate.Text = "";
            chkNesting.Checked = true;
            txtArguments.Text = "0";


            if (YCodeCreated != null)
            {
                YCodeCreated(this, new EventArgs());
            }
        }
    }
}
